package com.base.app_core.util.liteorm;

import com.litesuits.orm.db.assit.WhereBuilder;

import java.util.List;

/**
 * Created by Administrator on 2016/5/10 0010.
 */
public class DBHandleEvent {
    public static final int OBJECT_SAVE = 0x01;
    public static final int OBJECT_DELETE = 0x02;
    public static final int OBJECT_UPDATE = 0x03;
    public static final int CLEAR_TABLE = 0x04;
    public static final int ORDER_ASC = 0x05;
    public static final int ORDER_DESC = 0x06;
    public static final int DATA_OBJ = 0x07;
    public static final int DATA_ARRAY = 0x08;
    public static final int DB_SQL=0x09;
    public static final int OBJECT_INSERT=0x0a;
    public Class beanclass;
    public Object beanobj;
    public List<? extends Object> beanList;
    int nHandleType;
    int nDataType = 0;
    UseDBName mUseDBName=null;
    private String mSql=null;//SQL语句
    private String[] strargs=null;
    private WhereBuilder mWherebuilder=null;

    public DBHandleEvent(Class beanclass, String mSql, String[] strargs, int nHandleType) {
        this.beanclass = beanclass;
        this.mSql = mSql;
        this.strargs = strargs;
        this.nHandleType = nHandleType;
        mUseDBName= (UseDBName) beanclass.getAnnotation(UseDBName.class);
    }

    public DBHandleEvent(Class beanclass, String mSql, int nHandleType) {
        this.beanclass = beanclass;
        this.mSql = mSql;
        this.nHandleType = nHandleType;
        mUseDBName= (UseDBName) beanclass.getAnnotation(UseDBName.class);
    }

    public String getmSql() {
        return mSql;
    }

    public String[] getStrargs() {
        return strargs;
    }

    public Class getBeanclass() {
        return beanclass;
    }

    public WhereBuilder getmWherebuilder() {
        return mWherebuilder;
    }

    public DBHandleEvent addWhereArgs(WhereBuilder whereBuilder){
        this.mWherebuilder=whereBuilder;
        return this;
    }

    public DBHandleEvent(Class _beanclass, Object _beanobj, int _nHandleType) {
        beanclass = _beanclass;
        beanobj = _beanobj;
        nHandleType = _nHandleType;
        nDataType = DATA_OBJ;
        mUseDBName= (UseDBName) _beanclass.getAnnotation(UseDBName.class);
    }
    public DBHandleEvent(WhereBuilder whereBuilder, int _nHandleType){
        this.mWherebuilder=whereBuilder;
        this.nHandleType=_nHandleType;
        beanclass = whereBuilder.getTableClass();
        mUseDBName= (UseDBName) beanclass.getAnnotation(UseDBName.class);

    }
    public int getnDataType() {
        return nDataType;
    }

    public DBHandleEvent(Class _beanclass, List<? extends Object> _beanList, int _nHandleType, int _nDatatype) {
        beanclass = _beanclass;
        beanList = _beanList;
        nHandleType = _nHandleType;
        nDataType = DATA_ARRAY;
        mUseDBName= (UseDBName) _beanclass.getAnnotation(UseDBName.class);
    }

    public UseDBName getUseDBName() {
        return mUseDBName;
    }

    public void setBeanclass(Class _beanclass) {
        beanclass = _beanclass;
    }

    public Object getBeanobj() {
        return beanobj;
    }

    public void setBeanobj(Object _beanobj) {
        beanobj = _beanobj;
    }

    public int getnHandleType() {
        return nHandleType;
    }

    public void setnHandleType(int _nHandleType) {
        nHandleType = _nHandleType;
    }

    public List<? extends Object> getBeanList() {
        return beanList;
    }

    public void setBeanList(List<Object> beanList) {
        this.beanList = beanList;
    }
}
